const state = {
  projectListData: new Object(),
  billprojectListData: new Object(),
  searchHistory: null,
  billSearchHistory: null
};

const getters = {
  project(state) {
    return state.projectListData
  },
  getSearchHistory(state) {
    return state.searchHistory
  },
  billSearchHistory(state) {
    return state.billSearchHistory
  }
};

const mutations = {
  // 保存项目信息数据
  SET_PROJECTLISTDATA (state, data) {
    state.projectListData = data;
  },
  SET_BILLPROJECTLISTDATA (state, data) {
    state.billprojectListData = data;
  },
  // 保存项目信息筛选记录, 用于下次判断是否根据筛选记录来请求数据。
  SET_SEARCHHISTORY (state, data){
    state.searchHistory = data;
  },
  // 保存制单项目信息筛选记录, 用于下次判断是否根据筛选记录来请求数据。
  SET_BILLSEARCHHISTORY(state, data) {
    state.billSearchHistory = data;
  }
};

const actions = {
  // 触发改变项目列表数据
  storageProjectList ( {commit}, data ) {
    commit('SET_PROJECTLISTDATA',data)
  },
  // 触发改变项目列表数据的历史搜索记录
  storageSearchHistory ({commit}, data) {
    commit('SET_SEARCHHISTORY', data)
  },

  // 触发改变单据项目列表数据
  storageBillProjectList ( {commit}, data ) {
    commit('SET_BILLPROJECTLISTDATA',data);
  },
  // 触发存储改变项目列表数据的历史搜索记录
  storagebillSearchHistory({commit}, data){
    console.log(data);
    commit('SET_BILLSEARCHHISTORY', data)
  }


};

export default {
  state,
  getters,
  actions,
  mutations
}
